# Contributor: Sean McAvoy <seanmcavoy@gmail.com>
# Maintainer: Sean McAvoy <seanmcavoy@gmail.com>
pkgname=greetd
pkgver=0.8.0
pkgrel=2
pkgdesc="Minimal and flexible login manager daemon"
url="https://git.sr.ht/~kennylevinsen/greetd"
arch="all !s390x !riscv64"  # limited by cargo/rust
license="GPL-3.0-only"
makedepends="cargo linux-pam-dev scdoc"
install="$pkgname.pre-install"
pkgusers="greetd"
pkggroups="greetd"
subpackages="$pkgname-doc $pkgname-openrc $pkgname-agreety"
source="$pkgname-$pkgver.tar.gz::https://git.sr.ht/~kennylevinsen/greetd/archive/$pkgver.tar.gz
	$pkgname.pam
	$pkgname.initd
	$pkgname.confd
	config.patch
	"
builddir="$srcdir/$pkgname-$pkgver"

export RUSTFLAGS="--remap-path-prefix=$builddir=/build/"

build() {
	cargo build --release --locked
	make -C man
}

check() {
	cargo check --locked
}

package() {
	install -Dm755 target/release/greetd "$pkgdir"/usr/sbin/greetd
	install -Dm755 target/release/agreety "$pkgdir"/usr/bin/agreety

	install -Dm644 config.toml "$pkgdir"/etc/greetd/config.toml
	install -Dm644 "$srcdir"/$pkgname.pam "$pkgdir"/etc/pam.d/$pkgname

	install -Dm755 "$srcdir"/$pkgname.initd "$pkgdir"/etc/init.d/$pkgname
	install -Dm644 "$srcdir"/$pkgname.confd "$pkgdir"/etc/conf.d/$pkgname

	make -C man install PREFIX=/usr DESTDIR="$pkgdir"
}

agreety() {
	pkgdesc="Simple, text-based greeter"
	depends="$pkgname"

	amove usr/bin/agreety
}

sha512sums="
40f007e38ca41faac97b3faba60e49d524c9e3afb4b594fcbc04a129701fa6177a915b2998e61f0ca615f4c8bd3078ef9fbd562c8fb72298f5605efd75a3f370  greetd-0.8.0.tar.gz
0f786b639223bf52445b7248756bc2e83a450a81e0750f853b70095a0438edb0c40ecc50df42cdb82838a068202787d5286ca5ebc363e6e1c4e969f122df5dfa  greetd.pam
51286430587a06851b2f45120e08b091dab252796011a59b66aa91fa9e4f9874ab398ffae0eae0159e0cb87cd27a6e478cede6df03a6c52a52d4625e9152554a  greetd.initd
f6c5d5755fb8cca3d45d6879557fb7fc85c40879bc570e6c9aac462ce9133a2fa0a03cbac1e598f8162a9136d3e6020cea808e16e1797f4d37d4cf7dfc94c11c  greetd.confd
da49e5993e2189567d0661ea63a69dafb650ab4a1dfebdfa346dff2e2c195d1d8fdb1f2cd4f9f64b26fd2c0b453df2886cd19d6afc59680b6fb4c54eab97c729  config.patch
"
